<?php
/**
 * 任务计划管理
 * ============================================================================

 * ============================================================================
 */
defined('BY_JYA') or exit('error');
//流拍
$auctions = pdo_getall('jy_jdpm_auction',array('mid'=>0,'endstatus'=>0,'endtime <='=>TIMESTAMP));
if($auctions){
	foreach($auctions as $a){
		 pdo_update('jy_jdpm_auction',array('endstatus'=>3),array('id'=>$a['id']));
	}
}
//生成拍卖订单
$auctions = pdo_fetchall('select id,order_id,order_no from '.tablename('jy_jdpm_auction').' where mid>0 AND (order_id is null OR order_id = 0) AND (order_no is null OR order_no=\'\') AND endstatus = 0 AND endtime <='.TIMESTAMP);
if($auctions){
	foreach($auctions as $auction){
		$_SESSION['uniacid']=$auction['uniacid'];
		$this->createOrder($auction['id']);
	}
}
//处理过期订单
$this->overdueOrder();
//自动收货
$this->automaticReceiving();
//每日入账、出金、余额数据生成，本部分有问题，暂不执行
//$this->payOut();
//设置提醒拍品：
$scheduled = pdo_getall('jy_jdpm_scheduled',array('mid'=>$_SESSION['uid']));
foreach($scheduled as $v){
		$auction =  pdo_get('jy_jdpm_auction',array('id'=>$v['pid'],'is_set'=>0));
		$msg =array('pname'=>$auction['pname']);
		if($auction['starttime'] < time()){
			$_SESSION['uniacid']=$auction['uniacid'];
			//set_sms2($oldmember['mobile'],$msg,2,$_SESSION['uid']);
			set_websms2('您关注的拍品《'.$auction['pname'].'》已经开拍了，请前往查看详情！',0,$_SESSION['uid'],$url='jy_jdpm/detail//id='.$v['pid']);
		}
}
if($_SESSION['uid']){
	exi('执行计划任务成功！','','goback');
}
exit('执行成功');